<style>
	
</style>
<template>
<div>
    <Card :bordered="false" dis-hover>
        <p slot="title" class="title">订单类（order）
        	<Button type="primary" class='fr'>添加子类</Button>
        </p>

        <Row :gutter="20">
        	<Col span="8">
	            <Card>
	                <p slot="title">物流订单：
	                	<Dropdown trigger="click" style="margin-left: 20px;float:right;">
					        <a href="javascript:void(0)">
					        	选择操作
					            <Icon type="arrow-down-b"></Icon>
					        </a>
					        <DropdownMenu slot="list">
					            <DropdownItem>发布文档</DropdownItem>
					            <DropdownItem>删除</DropdownItem>
					        </DropdownMenu>
					    </Dropdown>
	                </p>
	               <Row type="flex" justify="center" align="top" class="code-row-bg">
				        <Col size='12' :xs="{ span: 5, offset: 1 }" :lg="{ span: 6, offset: 2 }">资源总数</Col>
        				<Col size='12' :xs="{ span: 5, offset: 1 }" :lg="{ span: 6, offset: 2 }">新增数据</Col>
				    </Row>
				    <Row type="flex" justify="center" align="top" class="code-row-bg">
				        <Col size="big" :xs="{ span: 5, offset: 1 }" :lg="{ span: 6, offset: 2 }">23万</Col>
        				<Col size='12' :xs="{ span: 5, offset: 1 }" :lg="{ span: 6, offset: 2 }">4,235</Col>
				    </Row>
	              	<Row>
				        <Col span="8"><i class="admin_btn bef_no">管理</i></Col>
				        <Col span="8"><i class="admin_btn">属性管理</i></Col>
				        <Col span="8"><i class="admin_btn">规则配置</i></Col>
				    </Row>
	            </Card>
	        </Col>
	        <Col span="8">
	            <Card class='clearfix'>
	                <p slot="title">物流订单：
	                	<Dropdown trigger="click" style="margin-left: 20px;float:right;">
				        <a href="javascript:void(0)">
				        	选择操作
				            <Icon type="arrow-down-b"></Icon>
				        </a>
				        <DropdownMenu slot="list">
				            <DropdownItem>发布文档</DropdownItem>
				            <DropdownItem>删除</DropdownItem>
				        </DropdownMenu>
				   	 </Dropdown>
	                </p>
	             	<Row>
				        <Col span="8"><i class="admin_btn bef_no">类别管理</i></Col>
				        <Col span="8"><i class="admin_btn">属性管理</i></Col>
				        <Col span="8"><i class="admin_btn">规则配置</i></Col>
				    </Row>
	            </Card>
	        </Col>
	        <Col span="8">
	            <Card>
	                <p slot="title">物流订单：
	                		<Dropdown trigger="click" style="margin-left: 20px;float:right;">
						        <a href="javascript:void(0)">
						        	选择操作
						            <Icon type="arrow-down-b"></Icon>
						        </a>
						        <DropdownMenu slot="list">
						            <DropdownItem>发布文档</DropdownItem>
						            <DropdownItem>删除</DropdownItem>
						        </DropdownMenu>
						    </Dropdown>
	                </p>
	                <Row>
				        <Col span="8"><i class="admin_btn bef_no">类别管理</i></Col>
				        <Col span="8"><i class="admin_btn">属性管理</i></Col>
				        <Col span="8"><i class="admin_btn">规则配置</i></Col>
				    </Row>
	            </Card>
	        </Col>
<!-- 			<Col span="8">
				<div class="div_order">
					<p class="p_1">物流订单：</p>

					<div class="clearfix">
						<Col span="8">
							<i class="admin_btn">管理</i>
						</Col>
						<Col span="8">
							<i class="admin_btn">属性配置</i>
						</Col>
						<Col span="8">
							<i class="admin_btn">规则配置</i>
						</Col>
					</div>
				</div>
			</Col> -->
        </Row>
    </Card>
    <Modal
        :title="title"
        v-model="modal">
        
		<Row>
			<Col span="6">组织机构名称 ：</Col>
			<Col span="18"><Input v-model="value" placeholder="请输入" style="width: 300px" 
			disabled></Input></Col>
		</Row> <br>
		<Row>
			<Col span="6">地 址、电 话 ：</Col>
			<Col span="18"><Input v-model="addressPhone" placeholder="请输入" style="width: 300px"></Input></Col>
		</Row> <br>
		<Row>
			<Col span="6">开户行及帐号 ：</Col>
			<Col span="18"><Input v-model="bankAccount" placeholder="请输入" style="width: 300px"></Input></Col>
		</Row> <br>
		<Row>
			<Col span="6">单张开票金额(元)：</Col>
			<Col span="18"><Input v-model="invoiceMaxAmount" placeholder="请输入" style="width: 300px"></Input></Col>
		</Row>
        
         
		 
		 <div slot="footer">
            <Button @click="cancel()">关闭</Button>
			<Button @click="add()" v-show="title=='添加'">添加</Button>
			<Button @click="update()" v-show="title=='修改'">修改</Button>
        </div>
    </Modal>
	<user-edit @refresh="getuser"></user-edit>
</div>	
</template>
<script>
import UserEdit from "../Module/useredit.vue";
export default {
	components:{UserEdit},
	data (){
		return {
			cityList: [
                    {
                        value: '发布文档',
                        label: '发布文档'
                    },
                    {
                        value: '删除',
                        label: '删除'
                    },
                ],
            model2: '',
			modal:false,value:'',title:'添加',addressPhone:'',
			rightobj:{},
			bankAccount:'',invoiceMaxAmount:'',
			colors:['yellow','blue'],texts:['正常','禁用'],
			data2:[],
			page:{total:0,currentPage:1,pageSize:10},
			data:[
				
			]
		}
	},mounted(){
		$('._table').resizableColumns({});
	},methods:{
		changePage (pageNum){
			this.page.currentPage = pageNum;
     		this.getuser();
		},
		addtype(){
			var d=this.$refs.tree.getSelectedNodes();
			if(d.length>0){
				this.id=d[0].id;
			}else{
				this.$Message.error('请选择要添加的节点!');
				return ;
			}

			this.modal=true;
			this.title='添加'
			this.value='';
		},updatetype(){
			var d=this.$refs.tree.getSelectedNodes();
			
			if(d.length>0){
				this.id=d[0].guid;
				this.value=d[0].title;
				this.addressPhone=d[0].addressPhone;
				this.bankAccount=d[0].bankAccount;
				this.invoiceMaxAmount=d[0].invoiceMaxAmount;
			}else{
				this.$Message.error('请选择要修改的节点!');
				return ;
			}
			this.modal=true;
			this.title='修改'
			
		},deletetype(){
			var d=this.$refs.tree.getSelectedNodes();
			if(d.length>0){
				this.id=d[0].id;
				this.value=d[0].title
			}else{
				this.$Message.error('请选择要删除的节点!');
				return ;
			}
			this.$Modal.confirm({
                 title:'删除提示',
                 content: '<p>确定删除？</p>',
                 onOk:()=>{
                     this.axios.post('/',{id:this.id}).then((res)=>{
                        this.$Message.info(res.message);
                        this.getdata();
                    })
                }
            })
		},cancel(){
			this.modal=false;
		},add(){
			this.axios.post('/',{
				id:this.id,title:this.value,invoiceMaxAmount:this.invoiceMaxAmount,
				addressPhone:this.addressPhone,bankAccount:this.bankAccount
				}).then((res)=>{

			})
			this.modal=false;
			this.title='';
			this.$Message.success('添加成功!');
			this.getdata();
		},update(){
			this.axios.post('/company/update',
				{
					guid:this.id,name:this.value,
					bankAccount:this.bankAccount,addressPhone:this.addressPhone,
					invoiceMaxAmount:this.invoiceMaxAmount
				}).then((res)=>{
					//console.log(res);
					if(res.errorCode==0){
						this.modal=false;
						this.title='';
						this.$Message.success('修改成功!');
						this.getdata();
					}else{
						this.$Message.error(res.message);
					}
					
			})
			
		},getdata(){
			var id=this.$store.getters.getUserinfo.sysComGuid;
			//id=1;
			this.axios.post('/company/tree/'+id,{}).then((res)=>{
				console.log(res);
				var u=JSON.stringify(res);
				u=u.replace(/comName/g,'title');
				u=JSON.parse(u);
				var d=[{}];
				d[0].title=u.data.title;
				d[0].createDate=u.data.createDate;
				d[0].guid=u.data.guid;
				d[0].memo=u.data.memo;
				d[0].orgCode=u.data.orgCode;
				d[0].parentGuid=u.data.parentGuid;
				d[0].taxNo=u.data.taxNo;
				d[0].children=u.data.children;
				d[0].addressPhone=u.data.addressPhone;
				d[0].bankAccount=u.data.bankAccount;
				d[0].invoiceMaxAmount=u.data.invoiceMaxAmount;
				this.data2=d;
			})
		},deleteuser(item){
			this.$Modal.confirm({
                 title:'删除提示',
                 content: '<p>确定删除？</p>',
                 onOk:()=>{
                     this.axios.post('/user/delete/'+item.guid,{}).then((res)=>{
                     	if(res.errorCode==0){
                     		this.$Message.info(res.message);
                     		this.page.currentPage=1;
                        	this.getuser();
                     	}
                        
                    })
                }
            })
		},updateuser(item){
			//this.$bus.emit('bus_useredit',{
			// 	id:1,username:'cc',password:'111',realname:'a',state:1
			// })
			this.$bus.emit('bus_useredit',item);
		},adduser(){
			var d=this.$refs.tree.getSelectedNodes();
			
			if(d.length>0){
				this.id=d[0].guid;
				this.value=d[0].title
			}else{
				this.$Message.error('请选择要添加的节点!');
				return ;
			}
			this.$bus.emit('bus_useredit',{
				userName:'',userPwd:'',orgGuid:this.page.orgGuid,userType:null
			})
		},getuser(){
			this.axios.post('/user/findbypage',this.page).then((res)=>{
				console.log(res);
				if(res.errorCode==0){
					this.data=res.data.list;
					this.page.total=res.data.total;
					this.page.currentPage=res.data.pageNo  || 1;
				}
			})
		},change(){
			var d=this.$refs.tree.getSelectedNodes();
			this.page.orgGuid=d[0].guid;
			this.rightobj.title=d[0].title;
			this.rightobj.addressPhone=d[0].addressPhone;
			this.rightobj.bankAccount=d[0].bankAccount
			this.rightobj.invoiceMaxAmount=d[0].invoiceMaxAmount;
			this.getuser();
		}
	},created(){
		this.getdata();
	},activated(){
		this.getdata();
	}
}
</script>